#include "HiranipraShared.h"
#include "HCM/ComponentFactory.h"

#ifndef _SHARED_HCM_COMPONENT_REGISTRY_H_
#define _SHARED_HCM_COMPONENT_REGISTRY_H_

namespace Hiranipra {
	namespace HCM {

		typedef multimap<const HCMID, ComponentFactory*, LessHCMID> hcmmap;

		class ComponentRegistry
		{
		public:
			void Register( const ComponentFactory* factory );

			vector<const ComponentFactory*> GetFactories( HCMID typeId ) const;

			IComponent* AllocateDefault( HCMID typeId ) const;
			IComponent* Allocate( HCMID typeId, HCMID implId ) const;

			template<class T> T* AllocateDefault( HCMID typeId ) const { return ( T* )this->AllocateDefault( typeId ); }
			template<class T> T* Allocate( HCMID typeId, HCMID implId ) const { return ( T* )this->Allocate( typeId, implId ); }

		private:
			hcmmap		_factories;
		};

		typedef void (*HCMRegisterComponents_fn)( ComponentRegistry& registry );
	}
}

#endif // _SHARED_HCM_COMPONENT_REGISTRY_H_
